<%@page import="com.kaishengit.entity.CarItem"%>
<%@page import="com.kaishengit.entity.Prod"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'shopcar.jsp' starting page</title>
  </head>
  
  <body>
   	<h3>我的购物车</h3>
   	<a href="home.jsp">继续购物</a>
   	<table border="1" width="70%">
   		<tr>
   			<th>商品名称</th>
   			<th>单价</th>
   			<th>数量</th>
   			<th>总价</th>
   			<th>操作</th>
   		</tr>
   		<%
   			List<CarItem> list = (List<CarItem>)session.getAttribute("shopCar");
   			if(list != null) {
   			float total = 0f;
   			for(CarItem item : list) {
   				total += item.getPrice();
   		%>
   		<form action="editcar.jsp" method="post">
	   		<tr>
	   			<td><%=item.getProd().getProdName() %></td>
	   			<td><%=item.getProd().getPrice() %></td>
	   			<td>
	   				<input type="hidden" name="id" value="<%=item.getProd().getId()%>"/>
	   				<input type="text" name="num" style="width:40px" value="<%=item.getNum() %>"/>
	   				<input type="submit" value="修改"/>
	   			</td>
	   			<td><%=item.getPrice() %></td>
	   			<td><a href="#">删除</a></td>
	   		</tr>
   		</form>
   		<%} %>
   			
   		<tr>
   			<td colspan="5">合计：￥<%=total %></td>
   		</tr>
   		<%}else { %>
   			<tr>
   			<td colspan="5">购物车内没有商品，赶紧<a href="home.jsp">购买</a>！</td>
   		</tr>
   		<%} %>
   	</table>
   	<a href="order.jsp">进行结算</a>
  </body>
</html>
